package com.woniu.microassetserver.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniu.microassetserver.mapper.DevSystemMapper;
import com.woniu.microassetserver.service.DevSystemService;
import com.woniu.microcommonsserver.entity.DevSystemEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;


@Transactional(readOnly = true)
@Service
public class DevSystemServiceImpl implements DevSystemService {

    @Resource
    private DevSystemMapper devSystemMapper;

    @Override
    public PageInfo<DevSystemEntity> findAllByParams(int pageNum, int pageSize, DevSystemEntity devSystemEntity) {
        return PageHelper.startPage(pageNum,pageSize).
                doSelectPageInfo(()->devSystemMapper.findAllByParams(devSystemEntity));
    }

    @Override
    public DevSystemEntity findRPIById(Long id) {
        return devSystemMapper.findRPIById(id);
    }

    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    @Override
    public int saveDevSystem(DevSystemEntity devSystemEntity) {
        return devSystemMapper.saveDevSystem(devSystemEntity);
    }

    @Override
    public DevSystemEntity getOneById(Long id) {
        return devSystemMapper.getOneById(id);
    }

    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    @Override
    public int updateDevSystem(DevSystemEntity devSystemEntity) {
        return devSystemMapper.updateDevSystem(devSystemEntity);
    }


    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    @Override
    public int deleteDevSystem(Long id) {
        return devSystemMapper.deleteDevSystem(id);
    }
}